package untiring07_HelloJDBC;

import javax.imageio.ImageIO;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.BorderLayout;
import java.awt.Image;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.awt.Dimension;

public class SungJukAboutDialog extends JDialog{

public SungJukAboutDialog(JFrame p) {
	super(p);
	setSize(450, 300);
	setModalityType(ModalityType.DOCUMENT_MODAL);
	setTitle("프로그램 정보");
	
	getContentPane().setLayout(new BorderLayout());
	//이미지 객체 생성
	//이미지에 대한 확대/축소 작업을 위해 먼저 이미지를 메모리로 불러들여야 함
	// 이때 사용하는 클래스가 BufferedImage임
	BufferedImage image=null;
	try {
		image = ImageIO.read(getClass().getResource("/images/suji02.jpg"));
	} catch (IOException e) {
		e.printStackTrace();
	}
	//이미지를 지정한 크기로 축소
	Image resizeimg = image.getScaledInstance(300, 150, Image.SCALE_SMOOTH);
	//JLabel에 이미지 지정후 JFrame에 추가
	JLabel label = new JLabel(new ImageIcon(resizeimg));
	label.setPreferredSize(new Dimension(250, 150));
	getContentPane().add(label,BorderLayout.CENTER);
	
	JPanel westp = new JPanel();
	getContentPane().add(westp, BorderLayout.WEST);
	westp.setLayout(new BoxLayout(westp, BoxLayout.X_AXIS));
	
	JPanel eastp = new JPanel();
	getContentPane().add(eastp, BorderLayout.EAST);
	eastp.setLayout(new BoxLayout(eastp, BoxLayout.X_AXIS));
	
	JLabel introlbl = new JLabel("ㅎㅎㅎ");
	eastp.add(introlbl);
	
	JPanel southp = new JPanel();
	getContentPane().add(southp, BorderLayout.SOUTH);
	
	JButton okbtn = new JButton("확인");
	okbtn.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			//System.exit(0); //이걸쓰면 프로그램 종료기 떄문에 쓰면 안됨
			setVisible(false); // AboutDialog 를 화면에서 지우고
			dispose(); //AboutDialog 객체를 제거
			
		}
	});
	southp.add(okbtn);
	setVisible(true);
}
}
